#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>


int main()
{
    pid_t id = fork();
    if(id==0)
    {
        printf("child process is running,pid:%d\n",getpid());
        sleep(2);
        //execl("/usr/bin/ls","ls","-a","-l",NULL);
        char *const _argv[]={"ls","-a","-l",NULL};
        //execv("/usr/bin/ls",_argv);
        execvp("ls",_argv);
        exit(1);
    }
    else
    {
        printf("parent process is running,pid:%d\n",getpid());
        int status=0;
        pid_t id=waitpid(-1,&status,0);
        if(WIFEXITED(status))
        {
            printf("child process exit code:%d\n",WEXITSTATUS(status));
        }
    }
    return 0;
}